home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 1_0-2 / EARTHPLO / EP_CWIND.C < prev    next >
C/C++ Source or Header  |  1987-12-25  |  4KB  |  197 lines

  1. #include "ep.const.h"
  2. #include "ep.extern.h"
  3.  
  4. cWindowDataUpate(Resized) /************************************************************/
  5. Boolean    Resized;
  6. {
  7. char    s[64];
  8.  
  9.     MoveTo(75,82);
  10.     NumToString(GetCtlValue(latSB),s);
  11.     EraseRect(&latDataRect);
  12.     DrawString(s);
  13.  
  14.     MoveTo(82,162);
  15.     NumToString(GetCtlValue(lonSB),s);
  16.     EraseRect(&lonDataRect);
  17.     DrawString(s);
  18.  
  19.     MoveTo(73,242);
  20.     NumToString(GetCtlValue(altSB)*(long)altScale,s);
  21.     EraseRect(&altDataRect);
  22.     DrawString(s);
  23. }
  24.  
  25. cUpdate (Resized) /************************************************************/
  26. Boolean    Resized;
  27. {
  28. GrafPtr    thePort;
  29.  
  30.     GetPort (&thePort);
  31.  
  32.     PlotIcon(&iconRect,iconHandle);
  33.     DrawControls(thePort);
  34.  
  35.     MoveTo(0,51);    /* draw nice lines :-) */
  36.     LineTo(175,51);
  37.     MoveTo(0,54);
  38.     LineTo(175,54);
  39.  
  40.     TextFont(0);
  41.     MoveTo(60,30);
  42.     DrawString("\p╡EarthPlot v3");
  43.     MoveTo(9,82);
  44.     DrawString("\pLatitude:");
  45.     MoveTo(9,162);
  46.     DrawString("\pLongitude:");
  47.     MoveTo(9,242);
  48.     DrawString("\pAltitude:");
  49.     
  50.     cWindowDataUpate();
  51. }
  52.  
  53. cClose() /************************************************************/
  54. {
  55.     SkelWhoa ();
  56. }
  57.  
  58. cClobber() /************************************************************/
  59. {
  60. GrafPtr    thePort;
  61.  
  62.     GetPort (&thePort);                /* grafport of window to dispose of */
  63.     DisposeWindow ((WindowPtr) thePort);
  64. }
  65.  
  66. cActivate() /************************************************************/
  67. {
  68. }
  69.  
  70. pascal void Track(Control,partCode)
  71. ControlHandle    Control;
  72. int                partCode;
  73. {
  74. int        i,step;
  75. long    wait;
  76. long    waited;
  77. char    s[128];
  78.  
  79.     wait = 5;  /* ticks */
  80.  
  81.     if (partCode == 0) return;
  82.     
  83.     switch (partCode) {
  84.     case inUpButton:
  85.         step = -1;
  86.         break;
  87.     case inDownButton:
  88.         step = 1;
  89.         break;
  90.     case inPageUp:
  91.         step = -10;
  92.         break;
  93.     case inPageDown:
  94.         step = 10;
  95.         break;
  96.     }
  97.     
  98.     i = GetCtlValue(Control) + step;
  99.     
  100.     if (*Control == *latSB) {
  101.         if (i > 90) i = 90;
  102.         if (i <  0) i = 0;
  103.  
  104.         SetCtlValue(Control,i);
  105.  
  106.         EraseRect(&latDataRect);
  107.         MoveTo(75,82);
  108.         NumToString(GetCtlValue(latSB),s);
  109.         DrawString(s);
  110.         Delay(wait,&waited);
  111.     }
  112.  
  113.     if (*Control == *lonSB) {
  114.         if (i > 180) i = 180;
  115.         if (i <   0) i = 0;
  116.  
  117.         SetCtlValue(Control,i);
  118.  
  119.         EraseRect(&lonDataRect);
  120.         MoveTo(82,162);
  121.         NumToString(GetCtlValue(lonSB),s);
  122.         DrawString(s);
  123.         Delay(wait,&waited);
  124.     }
  125.  
  126.     if (*Control == *altSB) {
  127.         if (i > 180) i = 180;
  128.         if (i <   0) i = 0;
  129.  
  130.         SetCtlValue(Control,i);
  131.  
  132.         EraseRect(&altDataRect);
  133.         MoveTo(73,242);
  134.         NumToString(GetCtlValue(altSB)*(long)altScale,s);
  135.         DrawString(s);
  136.         Delay(wait,&waited);
  137.     }
  138. }
  139.  
  140. cMouse(thePoint,theTime,theMods) /************************************************************/
  141. Point    thePoint;
  142. long    theTime;
  143. int        theMods;
  144. {
  145. ControlHandle    theControl;
  146. int                partCode;
  147. char            s[100];
  148.  
  149.     partCode = FindControl(thePoint,cWindow,&theControl);
  150.  
  151.     if (partCode) {
  152.         switch (partCode) {
  153.         case inCheckBox:
  154.             partCode = TrackControl(theControl,thePoint,0L);
  155.             if (*theControl == *northCheck) {
  156.                 SetCtlValue(northCheck,1);
  157.                 SetCtlValue(southCheck,0);
  158.             }
  159.             if (*theControl == *southCheck) {
  160.                 SetCtlValue(northCheck,0);
  161.                 SetCtlValue(southCheck,1);
  162.             }
  163.             if (*theControl == *eastCheck) {
  164.                 SetCtlValue(eastCheck,1);
  165.                 SetCtlValue(westCheck,0);
  166.             }
  167.             if (*theControl == *westCheck) {
  168.                 SetCtlValue(eastCheck,0);
  169.                 SetCtlValue(westCheck,1);
  170.             }
  171.             if (*theControl == *mileCheck) {
  172.                 SetCtlValue(mileCheck,1);
  173.                 SetCtlValue(kmCheck,0);
  174.             }
  175.             if (*theControl == *kmCheck) {
  176.                 SetCtlValue(mileCheck,0);
  177.                 SetCtlValue(kmCheck,1);
  178.             }
  179.             break;
  180.         case inUpButton:
  181.         case inDownButton:
  182.         case inPageUp:
  183.         case inPageDown:
  184.             partCode = TrackControl(theControl,thePoint,Track);
  185.             break;
  186.         case inThumb:
  187.             partCode = TrackControl(theControl,thePoint,0L);
  188.             cWindowDataUpate(FALSE);
  189.             break;
  190.         }
  191.     }
  192. }
  193.  
  194. cKey() /************************************************************/
  195. {
  196. }
  197.